<?php
    $modifiedSoftware = ns_dao_software::SoftwareByID($_GET['id']);
    $categoryList = ns_dao_software::GetCategoryList();
    $userList = ns_dao_user::GetUsersList();
?>
    <div id="topMenu">
    <!--Corner/Side Divs-->
    <div class="topMenu-Top">
    <div class="topMenu-Bot">
    <div class="topMenu-Left">
    <div class="topMenu-Right">
    <div class="topMenu-BotL">
    <div class="topMenu-BotR">
    <div class="topMenu-TopL">
    <div class="topMenu-TopR">
    <!--Corner/Side Divs-->

    <table width="100%" border="0" cellpadding="1" cellspacing="1" align="center">
    <tr>
        <td class="highlightCell" align="center"><a href="my_projects.php?id=<?php echo $_GET['id'] ?>&view=manageDescr"><strong>Software Description</strong></a></td>
        <td class="highlightCell" align="center"><a href="my_projects.php?id=<?php echo $_GET['id'] ?>&view=manageIcon"><strong>Software Icon</strong></a></td>
        <td class="highlightCell" align="center"><a href="my_projects.php?id=<?php echo $_GET['id'] ?>&view=manageVersion"><strong>Software File Management</strong></a></td>
    </tr>
    </table>

    <!--Corner/Side Divs-->
    </div></div></div></div></div></div></div></div>
    <!--Corner/Side Divs-->
    </div>
    </div> <!-- End of topSection -->

    <form name="updateSoftware" action="my_projects.php" method="POST" onsubmit="return check_software_form()">
    <input type="hidden" name="softwareID" id="softwareID" value="<?php echo $_GET['id'] ?>"/>
    <table border="0" width="500" cellspacing="1" cellpadding="1">
        <tr>
            <td colspan="2"><strong>Software Item</strong></td>
        </tr>
        <tr>
            <td nowrap="nowrap" valign="top" width="10%">
                <font size="-1">Name:</font>
            </td>
            <td>
                <input name="Name" id="Name" size="30" value="<?php echo $modifiedSoftware->Name() ?>" type="text">
            </td>
        </tr>
        <tr>
            <td nowrap="nowrap" valign="top" width="10%">
                <font size="-1">Description:</font>
            </td>
            <td>
                <textarea name="Description" id="Description" rows="10" cols="50"><?php echo $modifiedSoftware->Description() ?></textarea>
            </td>
        </tr>                
        <tr>
            <td nowrap="nowrap" valign="top" width="10%">
                <font size="-1">Category:</font>
            </td>
            <td>
                <select name="Category" id="Category">
                <?php
                    foreach ($categoryList as $key => $category)
                    {
                        if ($category->ID() == $modifiedSoftware->Category())
                        {
                             echo '<option selected=selected value="' . $category->ID() . '">' . $category->ID() . " - " . $category->CategoryDescription() . "</option>";                                    
                        }
                        else
                        {
                            echo '<option value="' . $category->ID() . '">' . $category->ID() . " - " . $category->CategoryDescription() . "</option>";
                        }
                    }
                ?>
                </select>                        
            </td>
        </tr>
        <tr>
            <td nowrap="nowrap" valign="top" width="10%">
                <font size="-1">Owner:</font>
            </td>
            <td>
                <select name="Owner" id="Owner">
                <?php
                    foreach ($userList as $key => $user)
                    {
                        if ($user->Username() == $modifiedSoftware->Owner())
                        {
                             echo '<option selected=selected value="' . $user->Username() . '">' . $user->Username() . "</option>";                                    
                        }
                    }
                ?>  
                </select>                        
            </td>
        </tr>
        <tr>
            <td nowrap="nowrap" valign="top" width="10%">
                <font size="-1">Approved:</font>
            </td>
            <td>
            <?php
                if ($modifiedSoftware->Approved() == 0)
                {
            ?>      
                    <input type="radio" name="Approved" id="Not Approved" value="0" checked="checked" />Not Approved<br />
                    <input type="radio" name="Approved" id="Approved" value="1" disabled="disabled" />Approved
            <?php                            
                } else {
            ?>
                    <input type="radio" name="Approved" id="Not Approved" value="0" disabled="disabled" />Not Approved<br />
                    <input type="radio" name="Approved" id="Approved" value="1" checked="checked" />Approved
            <?php
                }
            ?>
            </td>
        </tr>
        <tr>
            <td colspan="1">&nbsp;</td>
            <td style="" align="left" nowrap="nowrap">
            <input type="submit" name="saveDescription" id="saveDescription" value="Save" style="font-weight: bold;" />
            <input type="button" name="cancel" id="cancel" value="Cancel" onclick="window.location.href ='my_projects.php'" />
            </td>
        </tr>
    </table>
    </form><br /><br />